<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>{$title}</title>
    <link rel="stylesheet" type="text/css" href="//cdn.bilnn.top/js/aui/aui.2.0.css"/>
    <style>
        body{

        }
    </style>
</head>
<body>
    <div class="aui-tab" id="tab">
        <div class="aui-tab-item {if $action=='send_gift'}aui-active{/if}" style="z-index: 1;" onclick="window.location.href='?c=gift&a=send_gift&id={$id}'">打赏礼物</div>
        <div class="aui-tab-item {if $action=='send_gift_log'}aui-active{/if}" style="z-index: 1;" onclick="window.location.href='?c=gift&a=send_gift_log&id={$id}'">打赏列表</div>
    </div>
   
    {if $action=='send_gift'}
    <div class="aui-content aui-margin-b-15" style="margin-bottom: 1.5rem !important;">
        <section class="aui-grid aui-margin-b-15">
            <h3 class="aui-text-info aui-margin-l-15 aui-margin-t-15 aui-ellipsis-1">打赏给：{$shares.source_name}<br>上传者：{$f_user.nick}</h3>
            <p class="aui-margin-l-15" style="font-size: 0.7rem;color: #757575;">上传者将获得礼物价值的9折分成(可提现)</p>
            <div class="aui-row" >
                {if $gift}
                {foreach from=$gift item=one}
                <div class="aui-col-xs-4">
                    <p><img src="/app{$one.gift_pic}" style="width: 4rem;"></p>
                    <p>{$one.gift_price}积分</p>
                    <div class="aui-grid-label">{$one.gift_name}*{$one.gift_num}</div>
                    <div class="aui-btn aui-btn-success" style="margin-top: 0.3rem" onclick="send_gift({$one.gift_id})">打赏</div>
                </div>   
                {/foreach}
                {else}
                <p class="aui-margin-b-15 aui-margin-t-15 aui-text-info" style="text-align: center;">您还没有礼物哦</p>
                {/if}
            </div>
        </section>
    </div>
    {/if}
    {if $action=='send_gift_log'}
        <section class="aui-grid aui-margin-b-15">
            <ul class="aui-list aui-media-list">
                {if $gift}
                {foreach from=$gift item=one}
                <li class="aui-list-item">
                    <div class="aui-media-list-item-inner">
                        <div class="aui-list-item-inner">
                            <div class="aui-card-list-user-avatar">
                                <img src="/app{$one.gift_pic}">
                            </div>
                            <div class="aui-list-item-text">
                                <div class="aui-list-item-title">{$one.gift_name}&nbsp;<span class="aui-text-primary">{if $one.gift_num>0}+{/if}{$one.gift_num}</span></div>
                                <div class="aui-list-item-right">{$one.ctime}</div>
                            </div>
                            <div class="aui-list-item-text aui-ellipsis-2">
                            赠送者：{$one.username}
                            </div>
                        </div>
                    </div>
                </li>
                {/foreach}
                {else}
                <li class="aui-list-item" style="display: flex;">
                    <div class="aui-media-list-item-inner">
                        <div class="aui-list-item-text">
                        还没有人打赏哦
                        </div>
                    </div>
                </li>
                {/if}
            </ul>
            <h3><div class="aui-pager" style="margin-left:0rem;margin-right:0rem"></div></h3>
        </section>
        {/if}
</div>
<footer class="aui-bar aui-bar-tab" id="footer">
    <div class="aui-bar-tab-item aui-active" tapmode>
        <a href='javascript:void(0)' onclick="window.location.href='?c=gift&a=index&backurl='+encodeURIComponent(window.location.href)">
            <i class="aui-iconfont aui-icon-cart"></i>
            <div class="aui-bar-tab-label">礼物商城</div>
        </a>
    </div>
    
</footer>
</body>
<script src="//apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="//cdn.bilnn.top/js/aui/aui-dialog.js"></script>
<script src="//cdn.bilnn.top/js/aui/aui-toast.js"></script>
<script src="//cdn.bilnn.top/js/aui/jquery.pagination.js"></script>
<script src="View/js/fun.js"></script>
<script>
    {if !empty($pager)}
    $('.aui-pager').pagination({
        totalData:{if $pager.total==0}1{else}{$pager.total}{/if},
        showData:{$pager.limit},
        current:{$pager.now},
        count:4,
        mode:'fixed',
        prevContent: '上页',
        nextContent: '下页',
        callback:function(e){
            var urls = window.location.href;
            if (urls.indexOf("page=")==-1){
                if (urls.indexOf("?")==-1){
                    urls = urls+"?page="+e.getCurrent();
                }else{
                    urls = urls+"&page="+e.getCurrent();
                }
            }else{
                urls = urls.split("page=");
                urls = urls[0];
                urls = urls+"page="+e.getCurrent();
            }
            window.location.href = urls;
        }
    });
    {/if}

    function send_gift(gift_id) {
        var dialog = new auiDialog();
        var toast = new auiToast();
        dialog.prompt({
            title:"打赏数量",
            text:'请输入打赏数量',
            intval:true,
            value:"1",
            buttons:['取消','确定']
        },function(ret){
            if(ret.buttonIndex == 2){
                if (ret.text==''){
                    toast.fail({
                        title:"打赏数量为空",
                        duration:2000
                    });
                }else{
                    var back = vpost("?c=gift&a=do_send_gift","sid={$shares.id}&gift_id="+gift_id+"&num="+ret.text);
                    if (back.code==0){
                        malert("提示：","打赏成功",1);
                    }else{
                        toast.fail({
                        title:back.msg,
                        duration:2000
                    });
                    }
                } 
            }
        })
    }
</script>
</html>